package com.ybkj.daijia.api.member.v1;

import com.ybkj.daijia.server.model.Area;
import com.ybkj.daijia.server.service.AreaService;
import com.ybkj.daijia.server.service.DriverService;
import com.ybkj.daijia.server.service.MemberAccountService;
import com.ybkj.daijia.server.service.MemberService;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 客户地区相关
 *
 * @author bo
 */
@Controller("memberAreaController")
@RequestMapping(value = "member/api/rest/v1")
public class AreaController {

    private static final Logger logger = LoggerFactory.getLogger(AreaController.class);

    @Autowired
    private MemberService memberService;
    @Autowired
    private MemberAccountService memberAccountService;
    @Autowired
    private DriverService driverService;
    @Autowired
    private AreaService areaService;


    @RequestMapping("listAreas")
    public ModelAndView listAreas() {

        List<Area> areas = areaService.listAll();

        ModelAndView mv = new ModelAndView();

        mv.addObject("arealist", areas);

        mv.setViewName("area/viewlist");

        return mv;

    }


    /**
     * 查询地区信息
     */
    @RequestMapping("areaDetail/{areaID}")
    public ModelAndView areaDetail(@PathVariable("areaID") Long areaID) {

        ModelAndView mv = new ModelAndView();

        Area area = areaService.findOne(areaID);

        mv.addObject("area", area);

        mv.setViewName("area/view");

        return mv;
    }

}
